<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>后台</title>

    <!-- Bootstrap -->
    <link href="/resource/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/resource/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/resource/css/admin.css"/>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/resource/js/vendor/html5shiv.js"></script>
    <script src="/resource/js/vendor/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<% include ../Admin/include/nav.html %> <!--顶部导航-->
<div class="container">
    <div class="row">
        <div class="col-sm-3 col-md-2">
            <% include ../Admin/include/sidebar.html %> <!--左侧菜单-->

        </div>
        <div class="col-sm-9 col-md-10 main">
            <h4 class="page-header"><span aria-hidden="true" class="glyphicon glyphicon-list"></span> 分类编辑</h4>
            <form action="/admin/category/edit" method="post" class="col-md-6 form-horizontal ">
                <div class="form-group">
                    <label for="catename" class="col-md-3 control-label">中文名称: (*) </label>
                    <div class="col-md-9">
                    <input type="text" class="form-control" id="catename" name="catename" value="<%=data[0].catename%>" placeholder="输入名称 ...">
                        </div>
                </div>
                <div class="form-group">
                    <label for="icon" class="col-md-3 control-label">选择图标:  </label>
                    <div class="col-md-9 input-group" style="padding: 0 15px">
                        <span class="input-group-addon"><i id="ico" class="fa <%=data[0].icon%>"></i></span><input type="text" class="form-control" id="icon" name="icon" value="<%=data[0].icon%>" placeholder="输入名称 ...">
                        <a class="input-group-addon" href="http://fontawesome.io/icons/" target="_blank" >查看图标</a>
                    </div>
                </div>
                <div class="form-group">
                    <label for="enname" class="col-md-3 control-label">英文名称:  </label>
                    <div class="col-md-9">
                        <input type="text" class="form-control" id="enname" name="enname" value="<%=data[0].enname%>" placeholder="输入名称 ...">
                    </div>
                </div>
                <div class="form-group">
                    <label for="alias" class="col-md-3 control-label">别名: </label>
                    <div class="col-md-9">
                    <input type="text" class="form-control" id="alias" name="alias" value="<%=data[0].alias%>" placeholder="输入别名 ...">
                        </div>
                </div>
                <div class="form-group">
                    <label for="taxis" class="col-md-3 control-label">排序: </label>
                    <div class="col-md-9">
                    <input type="text" class="form-control" id="taxis" name="taxis" value="<%=data[0].taxis%>" placeholder="排序 ...">
                        </div>
                </div>
                <div class="form-group">
                    <label for="pid" class="col-md-3 control-label">父分类: </label>
                    <div class="col-md-9">
                    <select class="form-control" id="pid" name="pid" <%if(ischild){%>disabled="disabled"<%}%>>
                        <option value="0">一级分类</option>
                        <%category.forEach(function(item){%>
                        <%if(item.cid != data[0].cid){%>
                        <option value="<%=item.cid%>" <%if(item.cid==data[0].pid){%>selected = "selected" <%}%>>|-<%=new Array(item.deep*2).join("-")%>  <%=item.catename%></option>
                        <%}%>
                        <%})%>

                    </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="description" class="col-md-3 control-label">描述: </label>
                    <div class="col-md-9">
                    <textarea class="form-control" id="description" name="description" rows="3"><%=data[0].description%></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="template" class="col-md-3 control-label">模板: </label>
                    <div class="col-md-9">
                    <select class="form-control" id="template" name="template">
                        <option value="<%=data[0].description%>">1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                        <option>5</option>
                    </select>
                    </div>
                </div>
                <hr/>
                <div class="">
                    <input type="hidden" name="cid" value="<%=data[0].cid%>">
                    <button type="submit" class="btn btn-primary">添加分类</button>
                </div>
            </form>


        </div>
    </div>
</div>
<% include ../Admin/include/footer.html %>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/resource/js/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/resource/js/bootstrap.min.js"></script>
<script>
    $("#icon").change(function(){
        var ico=$(this).val();
        var ocalss=$("#ico").attr("class");
        $("#ico").removeClass(ocalss).addClass("fa "+ico);

    })
</script>
</body>
</html>